package me.wangshier.leetcode.medium;

/**
 * 15. 最少前缀操作问题
 *
 * @Author: tongqianwen
 * @Date: 2025/3/7
 */
public class MinimumPrefixOperations {
    public static int solution(String S, String T) {
        int modify = 0;
        int i = 0;// 遍历S
        int j = 0;// 遍历T
        while (j < T.length() && i < S.length()) {
            if (S.charAt(i) != T.charAt(j)) {
                modify++;
            }
            i++;
            j++;
        }
        if (S.length() > T.length()) {
            modify += S.length() - T.length();
        }
        return modify;
    }

    public static void main(String[] args) {
        System.out.println(solution("aba", "abb") == 1);
        System.out.println(solution("abcd", "efg") == 4);
        System.out.println(solution("xyz", "xy") == 1);
        System.out.println(solution("hello", "helloworld") == 0);
        System.out.println(solution("same", "same") == 0);
    }
}
